import java.util.ArrayList;

/*
 * Created by Jesse Phillips
 * Created on 12-Jan-06
 */

public class Square extends Rectangle {

	public Square(double side) {
		super("Square", side, side);
	}
	
	public static String validate(double a, double b, double c, double d) {
		String error = Rectangle.validate(a, b, c, d);
		if(error == null)
			if(a != b)
			return "All Sides must be the same.";
			else 
				return null;
		else
			return error;
	}

	public static Square create(double a, double b, double c, double d) throws ShapeException {
		String error = Square.validate(a,b,c,d);
		if(error == null)
			return new Square(a);
		else {
			ArrayList<Double> foo = new ArrayList<Double>();
			foo.add(a);
			foo.add(b);
			foo.add(c);
			foo.add(d);
			throw new ShapeException("Square", error, foo);
		}
	}
}
